<% /**
	* settingsEmailConfirmation.jsp
	* 
	* Validates a user's email
	*
	* @author Samson, Oren, and Chris
	*/
%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="b1w1nn1ng.crossf1t.gui.*"%>
<%@page import="b1w1nn1ng.crossf1t.business.*"%>
<%@page import="b1w1nn1ng.crossf1t.db.*"%>

<%  
User user = (User) session.getAttribute("user");
session.setAttribute("user", user);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title> Change Email </title>
		<jsp:include page="/detectBrowser.jsp" />	
	</head>
	<body>
	
		<div id="container">
		<h1> Change Email </h1> <hr />
		<%
				
		if(Login.isValidEmail(request.getParameter("newEmail"))) {
			//If we don't have any errors, then we can ship the new email off to the database and
			//then display a confirmation page
			user.setEmail(request.getParameter("newEmail"));
			//TODO uncomment this when database works user.update();
			response.sendRedirect("../settings.jsp");
		} else {
			//display an error page.
			out.println("The email you entered was invalid. Please check that you have spelled your new email properly.<br /><br />");
			out.println("<input type=\"button\" value=\"Back\" onclick=\"window.location =\'settingsEmail.jsp\'\"/>");
		}
		 %>
		
		</div>
	</body>
</html>

